﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" 
    xmlns:viewmodel="clr-namespace:Moneyman.ViewModel;assembly=Moneyman.ViewModel"
    xmlns:UX="clr-namespace:Moneyman.UX;assembly=Moneyman.UX"
    xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
    xmlns:telerikControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
    xmlns:Converters="clr-namespace:Moneyman.Converters;assembly=Moneyman.Converters"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    x:Class="Moneyman.Wallet.MainPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

	<phone:PhoneApplicationPage.Resources>
		<Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <Converters:ResourceKeyToPathdataConverter x:Key="ResourceKeyToPathdataConverter"/>
        <Converters:NumberGreaterThanToVisibilityConverter x:Key="NumberGreaterThanToVisibilityConverter"/>
        
		<Storyboard x:Name="Roll" RepeatBehavior="Forever" AutoReverse="False">
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="circularPanel">
				<EasingDoubleKeyFrame KeyTime="0:0:10" Value="180"/>
				<EasingDoubleKeyFrame KeyTime="0:0:20" Value="360"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter" />
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:HomeViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush Stretch="{Binding GlobalSettings.ImageStretch}" ImageSource="{Binding GlobalSettings.BackgroundImageSource, Mode=OneWay}"/>
        </Grid.Background>

        <controls:Panorama Title="{StaticResource IDS_APP_NAME}" >
            <controls:PanoramaItem Header="首页">
                <ScrollViewer>
                    <StackPanel >
                        
                    </StackPanel>
                </ScrollViewer>
            </controls:PanoramaItem>
            <controls:PanoramaItem Header="交易">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="48"/>
                    </Grid.ColumnDefinitions>
                    <!--transaction info area-->
                    <ScrollViewer>
                        <StackPanel>
                            <TextBlock Text="金额" Style="{StaticResource PhoneTextSubtleStyle}" />
                            <TextBox Name="textAmount" Text="{Binding NewTransactionItemToAdd.Amount, Mode=TwoWay}" InputScope="Number"/>
                            
                            <TextBlock Text="交易时间" Style="{StaticResource PhoneTextSubtleStyle}" />
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                
                                <toolkit:DatePicker Value="{Binding NewTransactionItemToAdd.Time, Mode=TwoWay}"/>
                                <toolkit:TimePicker Grid.Column="1" Value="{Binding NewTransactionItemToAdd.Time, Mode=TwoWay}"/>
                            </Grid>

                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>

                                <toolkit:ListPicker Header="交易类型" ItemsSource="{Binding ShowCategoryCollection}" SelectedItem="{Binding Path=SelectedCategory}">
                                    <toolkit:ListPicker.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <Path Data="{Binding IconResourceKey, Converter={StaticResource ResourceKeyToPathdataConverter}}" 
                                                      Stretch="Uniform" Fill="#FF818181" 
                                                      Width="20" Height="20" Margin="0,0,0,0" 
                                                      RenderTransformOrigin="0.5,0.5">
                                                    <Path.RenderTransform>
                                                        <TransformGroup>
                                                            <RotateTransform Angle="0" />
                                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                                        </TransformGroup>
                                                    </Path.RenderTransform>
                                                </Path>
                                                <TextBlock Text="{Binding Name}" Margin="12,0" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </toolkit:ListPicker.ItemTemplate>
                                    <toolkit:ListPicker.FullModeItemTemplate>
                                        <DataTemplate>
                                            <Grid Margin="12,6">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="auto"/>
                                                    <ColumnDefinition/>
                                                </Grid.ColumnDefinitions>
                                                <Path Data="{Binding IconResourceKey, Converter={StaticResource ResourceKeyToPathdataConverter}}" 
                                                      Fill="#FF818181" Height="36" Margin="0,0,0,0"
                                                      RenderTransformOrigin="0.5,0.5" Stretch="Uniform" Width="36">
                                                    <Path.RenderTransform>
                                                        <TransformGroup>
                                                            <RotateTransform Angle="0"/>
                                                            <ScaleTransform ScaleY="1" ScaleX="1"/>
                                                        </TransformGroup>
                                                    </Path.RenderTransform>
                                                </Path>
                                                <TextBlock Grid.Column="1" 
                                                           Margin="12,0" 
                                                           Style="{StaticResource PhoneTextTitle2Style}" 
                                                           Text="{Binding Name}"/>
                                            </Grid>
                                        </DataTemplate>
                                    </toolkit:ListPicker.FullModeItemTemplate>
                                </toolkit:ListPicker>
                                <toolkit:ListPicker Header="支付方式" Grid.Column="1" ItemsSource="{Binding EnumsOfPaymentWays, Mode=OneWay}" SelectedItem="{Binding NewTransactionItemToAdd.Paymentway}">
                                    <toolkit:ListPicker.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Converter={StaticResource EnumTranslateConverter}}"/>
                                        </DataTemplate>
                                    </toolkit:ListPicker.ItemTemplate>
                                </toolkit:ListPicker>
                            </Grid>

                            <TextBlock Text="说明" Style="{StaticResource PhoneTextSubtleStyle}" />
                            <TextBox AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding NewTransactionItemToAdd.Remark, Mode=TwoWay}"/>

                            <TextBlock Text="地点" Style="{StaticResource PhoneTextSubtleStyle}" />
                            <toolkit:AutoCompleteBox/>
                            
                            <CheckBox Content="关联事件" IsChecked="{Binding LinkToCase, Mode=TwoWay}"/>
                            <toolkit:AutoCompleteBox Visibility="{Binding LinkToCase, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        </StackPanel>
                    </ScrollViewer>
                    
                    <!--submit & cancel buttons-->
                    <StackPanel VerticalAlignment="Bottom"  Grid.Column="1" >
                        <UX:UXPathButton IconPath="{StaticResource PATH_ICON_SUBMIT}" Command="{Binding AddNewTransactionCommand, Mode=OneWay}" />
                        <UX:UXPathButton IconPath="{StaticResource PATH_ICON_CLOSE}" Padding="13" Margin="0,12" Command="{Binding Path=CancelAddCommand}" />
                    </StackPanel>
                </Grid>
            </controls:PanoramaItem>
            <controls:PanoramaItem Header="菜单" >
                <ScrollViewer>
                    <StackPanel>
                        <UX:UXTextMenu Content="流水账" Margin="0,0,0,6" Uri="/Views/TransactionsDailyView.xaml"/>
                        <UX:UXTextMenu Content="交易分类"/>
                        <UX:UXTextMenu Content="每月开支预算"/>
                        <UX:UXTextMenu Content="关联事件"/>
                        <UX:UXTextMenu Content="银行卡管理"/>
                        <UX:UXTextMenu Content="收支统计"/>
                        <UX:UXTextMenu Content="常用地点"/>
                        <UX:UXTextMenu Content="偏好设置"/>
                        <UX:UXTextMenu Content="关于和帮助"/>
                    </StackPanel>
                </ScrollViewer>
            </controls:PanoramaItem>
        </controls:Panorama>

    </Grid>

</phone:PhoneApplicationPage>